package com.interagriculture.utils;

import org.apache.commons.lang3.RandomStringUtils;

/**
 * @author 11 2024/11/9
 */
public class StringTools {
    public static boolean isEmpty(String str){
        if(null == str || "".equals(str) || "null".equals(str) || "\u0000".equals(str)){
            return true;
        }else if("".equals(str.trim())) {
            return true;
        }
        return false;
    }

    public static String getRandomNumber(Integer count){
        return RandomStringUtils.random(count,false,true);
    }
    public static String getRandomString(Integer count){
        return RandomStringUtils.random(count,true,true);
    }

    public static String cleanHtmlTag(String content) {
        if(isEmpty(content)){
            return content;
        }
        //对消息转译
        content = content
                .replace("<","&lt;")
                .replace("\r\n","<br>")
                .replace("\n","<br>");

        return content;
    }


    public static boolean isNumber(String str){
        String checkNumber = "^[0-9]+$";
        if(null == str){
            return false;
        }
        if(!str.matches(checkNumber)){
            return false;
        }
        return true;
    }

}
